/**
 * Description: 登录
 *
 * @author      Eden
 * @datetime    2016/11/25 09:30
 * @copyright   Beijing CmsTop Technology Co.,Ltd.
 */

(function () {
    "use strict";

    var api = {
        bankUrl: 'money/bank/info',
        blankSaveUrl: "money/bank/save"
    };

    sm.controller('admin-money-purchaser-blank', ['$scope', '$http', 'Modal', function ($scope, $http, Modal) {

        $scope.bank = {
            bankname: "",
            kaihuhang: "",
            username: "",
            account: ""
        };

        $scope.getInfo = function () {
            $http.get(api.bankUrl).success(function (res) {
                if (res.state) {
                    $scope.bank = res.data;
                }
            });
        };

        $scope.getInfo();

        $scope.submit = function () {

            if (!$scope.bank.bankname || !$scope.bank.kaihuhang || !$scope.bank.username || !$scope.bank.account) {
                Modal.error('请将银行卡信息填写完整');
                return
            }

            $http.post(api.blankSaveUrl, $scope.bank).success(function (res) {
                if (res.state) {
                    Modal.alert({
                        title: "操作提示",
                        content: "银行卡信息编辑成功"
                    });
                } else {
                    Modal.error(res.error ? res.error : "编辑失败，请重试");
                }
            });

        }

    }]);

})();

